<script setup>
import { ref } from 'vue';

import MyButton from './MyButton.vue';
const state = ref({});

function loadData() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({ data: "数据加载完成" })
    }, 1000)
  })
}

async function testClick() {
  console.log("testClick 函数调用 ..");
  state.value = await loadData();
}


</script>
<template>
  <div class="wrap">
    <my-button type="primary" @click="testClick">
      获取数据1111
    </my-button>
    <div>
      {{ state }}
    </div>
  </div>

</template>

<style scoped>
.wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>